<html>
<head>
    <title>修改页面</title>
</head>
<body>
<form action="/employee/updateEmployee">
    <table>
        <tr>
            <td></td>
            <td><input type="hidden" name="id" id="id" value="${employee.id}"></td>
        </tr>
        <tr>
            <td>用户名</td>
            <td><input type="text" name="username" id="username" value="${employee.username}"></td>
        </tr>
        <tr>
            <td>密码</td>
            <td><input type="password" name="password" id="password" value="${employee.password}"></td>
        </tr>
        <tr>
            <td>生日</td>
            <td><input type="text" name="birthday" id="birthday" value="${employee.birthday?string('yyyy-MM-dd')}"></td>
        </tr>
        <tr>
            <td>入职日期</td>
            <td><input type="text" name="entry_date" id="entry_date" value="${employee.entry_date?string('yyyy-MM-dd')}"></td>
        </tr>
        <tr>
            <td>职位</td>
            <td><input type="text" name="job" id="job" value="${employee.job}"></td>
        </tr>
        <tr>
            <td>薪水</td>
            <td><input type="text" name="salary" id="salary" value="${employee.salary}"></td>
        </tr>
        <tr>
            <td>毕业院校</td>
            <td><input type="text" name="resume" id="resume" value="${employee.resume}"></td>
        </tr>
        <tr>
            <td><input type="button" id="saveBtn" value="修改"></td>
            <td><input type="button" id="cancelBtn" value="取消"></td>
        </tr>
    </table>
</form>

<script src="/js/jquery/jquery.min.js"></script>
<script>
    var editEmployee = function () {
        $.ajax({
            type:"PUT",
            dataType:"json",
            url:"/employee/updateEmployee/"+$("#id").val(),
            data:{
                "username":$("#username").val(),
                "password":$("#password").val(),
                "birthday":$("#birthday").val(),
                "entry_date":$("#entry_date").val(),
                "job":$("#job").val(),
                "salary":$("#salary").val(),
                "resume":$("#resume").val()
            },
            success:function (msg) {
                alert("data edit:"+msg.code+","+msg.msg);
                $("#cancelBtn").click();
            }
        });
    }

    $("#saveBtn").on("click",function () {
        editEmployee();
    });

</script>

</body>
</html>
